package com.xqboss.apps.service.hama;

import cn.hutool.core.lang.Assert;
import com.xqboss.apps.domain.hama.HamaOpenConfig;
import com.xqboss.apps.mapper.hama.HamaOpenConfigMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xqboss.common.exception.ServiceException;
import org.springframework.stereotype.Service;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 开辟灵池 服务实现类
 * </p>
 *
 * @author 木鱼
 * @since 2024-02-28
 */
@Service
@Slf4j
@RequiredArgsConstructor
public class HamaOpenConfigService extends ServiceImpl<HamaOpenConfigMapper, HamaOpenConfig> {

    /**
     * 添加建设某配置运动场的人数
     *
     * @param openId 运动场配置id
     * @param number 建设某配置运动场的人数
     */
    @Transactional
    public void addBuildSportNumber(Long openId,Integer number){
        boolean update = this.lambdaUpdate().setSql("number = number + " + number).eq(HamaOpenConfig::getId, openId).update();
        Assert.isTrue(update,()->new ServiceException("添加创建人数失败~"));
    }

}